'''
多任务协程，执行多个task
'''
import asyncio
import requests


async def request():
    url ='http://www.baidu.com'
    response = requests.get(url)
    return response
# 创建一个task列表
tasks = []
for i in range(5):
    coroutine = asyncio.ensure_future(request())
    tasks.append(coroutine)
# 也可使使用列表解析，创建一个列表

tasks = [asyncio.ensure_future(request()) for _ in range(5)]

# 运行
loop = asyncio.get_event_loop()
loop.run_until_complete(asyncio.wait(tasks))

for task in tasks:
    print("taskResult",task.result(),"aaaa")
    